package com.origin.app.page.company_list

import android.content.Intent
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.origin.app.MyApplication
import com.origin.app.R
import com.origin.app.databinding.ActivityCompanyListBinding
import com.origin.app.page.base.BaseActivity
import com.origin.app.page.company_list.adapter.CompanyAdapter

class CompanyListActivity  : BaseActivity<ActivityCompanyListBinding, CompanyListViewModel>(R.layout.activity_company_list) {

    private val companyAdapter: CompanyAdapter by lazy {
        CompanyAdapter( viewModel.companyBeanList,this);
    }
    companion object {
        fun launcher() {
            MyApplication.getInstance().getCurrentActivity()?.apply {
                val intent = Intent(this, CompanyListActivity::class.java)
                startActivity(intent)
            }
        }
    }
    override fun initContentView() {
        viewModel.getCompanyListUrl();

        contentViewBinding.recyclerView.layoutManager= LinearLayoutManager(mContext)
        contentViewBinding.recyclerView.adapter=companyAdapter

        contentViewBinding.recyclerView.setHasFixedSize(true)
    }

    override fun setMutableLiveDataListener() {
        viewModel.refreshListMutableLiveData.observe(this){
            companyAdapter.notifyDataSetChanged()
        }
    }

}